package com.sgzn.sgpay.persistence.manager;

import com.sgzn.sgpay.enums.EnumDevicePresentLogTradeMark;
import com.sgzn.sgpay.persistence.dao.TPresentReadMapper;
import com.sgzn.sgpay.persistence.request.TPresentReadRequest;
import com.sgzn.sgpay.persistence.response.TPresentRead;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author huangsenguang
 * @version Id: PresentReadManager.java, v 0.1 2018/6/3 18:13 huangsenguang Exp $$
 */
@Component
public class PresentReadManager {
    @Resource
    private TPresentReadMapper tPresentReadMapper;

    public List<TPresentRead> gettPresentReads(Date beginTime, Date endTime, List<String> deviceIdList) {
        if (CollectionUtils.isEmpty(deviceIdList)) {
            return new ArrayList<TPresentRead>(0);
        }
        TPresentReadRequest tPresentReadRequest = new TPresentReadRequest();
        tPresentReadRequest.setDeviceIdList(deviceIdList);
        tPresentReadRequest.setBeginTime(beginTime);
        tPresentReadRequest.setEndTime(endTime);
        tPresentReadRequest.setOperType(EnumDevicePresentLogTradeMark.DECREASE.getCode());
        return this.tPresentReadMapper.query(tPresentReadRequest);
    }

    public List<TPresentRead> gettPresentReads(List<String> deviceIdList) {
        if (CollectionUtils.isEmpty(deviceIdList)) {
            return new ArrayList<TPresentRead>(0);
        }
        TPresentReadRequest tPresentReadRequest = new TPresentReadRequest();
        tPresentReadRequest.setDeviceIdList(deviceIdList);
        tPresentReadRequest.setOperType(EnumDevicePresentLogTradeMark.DECREASE.getCode());
        return this.tPresentReadMapper.query(tPresentReadRequest);
    }
}

